var dom003 =
  '<div id="p0y1" class="bx-nav height-light-area">\
<ul id="p0y1ul" class="nav-list1">\
</ul>\
</div>\
<div id="p0y2">\
<div id="AREA003">\
<div id="AREA001x0" class="left-arrow"><img src="/custom-templates/images/home/xiangzuo.png"></div>\
<div id="AREA003x1">\
    <div id="AREA003x1x0">\
        <div id="AREA003x1x0y0" class="pos-box-style" tabindex="-1 ">\
        </div>\
        <div id="AREA003x1x0y1" class="pos-box-style" tabindex="-1 ">\
        </div>\
    </div>\
    <div id="AREA003x1x1">\
        <div id="AREA003x1x1y0">\
            <div id="AREA003x1x1y0x0" class="pos-box-style" tabindex="-1 ">\
            </div>\
            <div id="AREA003x1x1y0x1" class="pos-box-style" tabindex="-1 ">\
            </div>\
        </div>\
        <div id="AREA003x1x1y1">\
            <div id="AREA003x1x1y1x0">\
                <ul id="AREA003x1x1y1x0ul" class="pos-box-style">\
                </ul>\
            </div>\
            <div id="AREA003x1x1y1x1" class="pos-box-style" tabindex="-1 ">\
            </div>\
        </div>\
    </div>\
</div>\
<div id="AREA001x0" class="left-arrow"><img src="/custom-templates/images/home/xiangyou.png"></div>\
</div></div>';

var pageData003 = {
  data: {
    x0y0: {
      type: "tag",
      data: [
        {
          $rowid: "0005",
          img: "/custom-templates/images/defaultImg2.png",
          title: "占位文字"
        }
      ]
    },
    x0y1: {
      type: "tag",
      data: [
        {
          $rowid: "0005",
          img: "/custom-templates/images/defaultImg2.png",
          title: "占位文字"
        }
      ]
    },
    x1y0x0: {
      type: "tag",
      data: [
        {
          $rowid: "0008",
          img: "/custom-templates/images/defaultImg2.png",
          title: "占位文字"
        }
      ]
    },
    x1y0x1: {
      type: "tag",
      data: [
        {
          $rowid: "0008",
          img: "/custom-templates/images/defaultImg2.png",
          title: "占位文字"
        }
      ]
    },
    x1y1x0: {
      type: "ul",
      data: [
        {
          $rowid: "0006",
          img: "/custom-templates/images/defaultImg2.png",
          title: "占位文字"
        },
        {
          $rowid: "0007",
          img: "/custom-templates/images/defaultImg2.png",
          title: "占位文字"
        },
        {
          $rowid: "0006",
          img: "/custom-templates/images/defaultImg2.png",
          title: "占位文字"
        },
        {
          $rowid: "0007",
          img: "/custom-templates/images/defaultImg2.png",
          title: "占位文字"
        }
      ]
    },
    x1y1x1: {
      type: "tag",
      data: [
        {
          $rowid: "0008",
          img: "/custom-templates/images/defaultImg2.png",
          title: "占位文字"
        }
      ]
    }
  }
};

window.initArea003 = function() {
  fillNowArea(pageData003.data, "003");
};

window.OPTIONS = {
  AREA003x1x0y0: {
    count: 1, // 资源个数
    area: "x0y0",
    areaType: "area",
    areaId: "003"
  },
  AREA003x1x0y1: {
    count: 1, // 资源个数
    area: "x0y1",
    areaType: "area",
    areaId: "003"
  },
  AREA003x1x1y0x0: {
    count: 1, // 资源个数
    area: "x1y0x0",
    areaType: "area",
    areaId: "003"
  },
  AREA003x1x1y0x1: {
    count: 1, // 资源个数
    area: "x1y0x1",
    areaType: "area",
    areaId: "003"
  },
  AREA003x1x1y1x0: {
    count: 4, // 资源个数
    area: "x1y1x0",
    areaType: "area",
    areaId: "003"
  },
  AREA003x1x1y1x1: {
    count: 1, // 资源个数
    area: "x1y1x1",
    areaType: "area",
    areaId: "003"
  }
};

//生成推荐位
function fillNowArea(data, id) {
  for (var ele in data) {
    var eleData = data[ele].data;
    if (data[ele].type == "tag") {
      $.each(eleData, function(index, eleTag) {
        $("#AREA" + id + "x1" + ele).html(
          '<button class="btn btn-primary uploadPicBtn" type="submit">上传图片</button><img src="' +
            eleTag.img +
            '"><p>' +
            eleTag.title +
            "</p>"
        );
      });
    } else if (data[ele].type == "ul") {
      $.each(eleData, function(index, eleLi) {
        $("#AREA" + id + "x1" + ele + "ul").append(
          '<li class="ver-box-style"><button class="btn btn-primary uploadPicBtn" type="submit">上传图片</button><img src="' +
            eleLi.img +
            '"><p>' +
            eleLi.title +
            "</p></li>"
        );
      });
    }
  }
}

var divs = [
  "AREA003x1x0y0",
  "AREA003x1x0y1",
  "AREA003x1x1y0x0",
  "AREA003x1x1y0x1",
  "AREA003x1x1y1x0",
  "AREA003x1x1y1x1"
];
$("#custom-template-wrap").html(dom003);

addHeadList('点播');
initArea003();

function bottomScroll() {
  var scroll = $("#p0y3x1")[0];
  var div1 = $("#con1")[0];
  var div2 = $("#con2")[0];
  // 如果文字超出可显示范围，则开始滚动
  if (div1.offsetWidth >= scroll.offsetWidth) {
    div2.innerHTML = div1.innerHTML;
    setInterval(function() {
      if (div1.offsetWidth <= scroll.scrollLeft) {
        scroll.scrollLeft -= div1.offsetWidth;
      } else {
        scroll.scrollLeft += 2;
      }
    }, 50);
  }
}

